#!/bin/bash

if [[ $# != 2 ]]; then
  echo "Usage: $0 force_file1 force_file_2" 1>&2
  exit -1
fi

if [ ! -f $1 ]; then
  echo "$1 missing" 1>&2
  exit 1
fi
if [ ! -f $2 ]; then
  echo "$2 missing" 1>&2
  exit 1
fi

# echo $1 $2
# head $1
# head $2

n=`head -1 $1 | sed 's/ //'g`

(paste $1 $2 | tail -$n | awk '{print $2-$6}' | sed 's/e/*10^/' | bc -l | sed 's/-//' ; \
paste $1 $2 | tail -$n | awk '{print $3-$7}' | sed 's/e/*10^/' | bc -l | sed 's/-//' ; \
paste $1 $2 | tail -$n | awk '{print $4-$8}' | sed 's/e/*10^/' | bc -l | sed 's/-//' ) | sort -k1n | tail -1
